package com.ticket.sass.admin.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.business.DouyinGoodBusiness;
import com.ticket.sass.admin.business.impl.DouyinGoodBusinessImpl;
import com.ticket.sass.admin.dto.input.douyin.DouyinuGoodUpdInput;
import com.ticket.sass.admin.dto.input.douyin.DouyinGoodExchangeSettingInput;
import com.ticket.sass.admin.dto.input.douyin.DouyinGoodListInput;
import com.ticket.sass.admin.dto.input.douyin.GetDouyinGoodExchangeSettingInput;
import com.ticket.sass.admin.dto.output.douyin.DouyinGoodExchangeSettingOutput;
import com.ticket.sass.admin.dto.output.douyin.DouyinGoodListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author ywb
 * @date 2024-07-19 11:26
 */
@RestController
@RequestMapping("/douyin/goods")
@Api(tags = "抖音卖品管理")
@ApiSupport(order = 8)
public class DouyinGoodController {
    final DouyinGoodBusiness business;
    
    public DouyinGoodController(DouyinGoodBusinessImpl filmBusiness) {
        this.business = filmBusiness;
    }
    
    @ApiOperation("列表")
    @GetMapping
    public ResultModel<PageModel<DouyinGoodListOutput>> list(
        @Valid DouyinGoodListInput input
    ) {
        return ResultModel.success(
            business.list(input)
        );
    }
    
    @PutMapping
    @ApiOperation("修改")
    public ResultModel<String> upd(
        @RequestBody @Valid DouyinuGoodUpdInput input
    ) {
        business.upd(input);
        return ResultModel.success();
    }
    
    @PostMapping("/exchange/setting")
    @ApiOperation("兑换设置")
    public ResultModel<String> exchangeSetting(
        @RequestBody @Valid DouyinGoodExchangeSettingInput exchangeSetting
    ) {
        business.exchangeSetting(exchangeSetting);
        return ResultModel.success();
    }
    
    @GetMapping("/exchange/setting")
    @ApiOperation("兑换设置")
    public ResultModel<DouyinGoodExchangeSettingOutput> getExchangeSetting(
        @Valid GetDouyinGoodExchangeSettingInput exchangeSetting
    ) {
        
        return ResultModel.success(        business.getExchangeSetting(exchangeSetting));
    }
    
    
    @PostMapping("/sync")
    @ApiOperation("同步")
    public ResultModel<String> sync() {
        business.sync();
        return ResultModel.success();
    }
}
